/**
 * 
 */
package it.uniroma3.dia.digraph.algorithm.utility.stackedtri.barycentric;

import it.uniroma3.dia.digraph.algorithm.stackedTri.ComparatorById;
import it.uniroma3.dia.digraph.algorithm.stackedTri.ConvexCoordMorphing;
import it.uniroma3.dia.digraph.algorithm.utility.stackedtri.StackedTriGraph;
import it.uniroma3.dia.digraph.algorithm.utility.stackedtri.StackedTriNode;

import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import org.graphdrawing.graphml.xmlns.EdgeType;
import org.graphdrawing.graphml.xmlns.GraphType;

/**
 * @author Cionzo
 *
 */
public class CombinationGraph {
    
//    private GraphType source, target;
    private Map<String, CombinationNode> nodeMap;
    private List<CombinationNode> allnodes;
    private List<EdgeType> edges;
    
    public CombinationGraph(StackedTriGraph source, StackedTriGraph target) {
	List<StackedTriNode> sDepth, tDepth;
	StackedTriNode s,t;
	Comparator<StackedTriNode> c = new ComparatorById(); 
	this.nodeMap = new HashMap<String, CombinationNode>();
	this.allnodes = new LinkedList<CombinationNode>();
	this.edges = source.getGraph().getEdgeCollection().getEdge();
	
	for (Integer i : source.getNodes().keySet()) {
	    sDepth = source.getNodes().get(i);
	    tDepth = target.getNodes().get(i);
	    
	    Collections.sort(sDepth, c);
	    Collections.sort(tDepth, c);
	    
	    for (int j=0; j<sDepth.size(); j++) {
		s = sDepth.get(j);
		t = tDepth.get(j);		
		this.allnodes.add(new CombinationNode(s, t, nodeMap));
	    }
	}
    }
    
    public List<CombinationNode> getAllNodes(){
	return this.allnodes;
    }

    /**
     * @return
     */
    public List<EdgeType> getEdges() {
	return this.edges;
    }

    /**
     * @return the nodeMap
     */
    public Map<String, CombinationNode> getNodeMap() {
        return nodeMap;
    }

    /**
     * @param nodeMap the nodeMap to set
     */
    public void setNodeMap(Map<String, CombinationNode> nodeMap) {
        this.nodeMap = nodeMap;
    }

}
